package com.loukou.lkt.lkt.dao;

import java.util.Date;
import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.transaction.annotation.Transactional;

import com.loukou.lkt.lkt.entity.AllocationOrder;

public interface AllocationOrderDao extends CrudRepository<AllocationOrder, Integer>,JpaSpecificationExecutor<AllocationOrder>{
	AllocationOrder findByOrderCode(String orderCode);
	
	@Modifying
	@Transactional
	@Query("update AllocationOrder set inOrdercode = ?3, orderState =?2, inTime=?4  where orderCode = ?1")
	void updateInOrderCode(String orderCode, int orderState, String wmsOrderCode, Date time);
	
	@Modifying
	@Transactional
	@Query("update AllocationOrder set outOrdercode = ?3, orderState = ?2, outTime=?4 where orderCode = ?1")
	void updateOutOrderCode(String orderCode,int orderState, String wmsOrderCode, Date time);
	
	@Modifying
	@Transactional
	@Query("update AllocationOrder set orderState = ?2 where id = ?1")
	void updateState(int orderId, int state);

	List<AllocationOrder> findByOrderState(int orderState);
}
